/* ========================================================================
 * Copyright 2007 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless reqired by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ========================================================================
 * Created on 12 nov. 2007
 * @author pollux
 */
package org.poxd.frisar.model;

/**
 *
 * 
 */
public class ElementId implements Comparable<ElementId>{
    private final Element TYPE;
    private final long start;

    public ElementId(Element el, long s)
    {
        TYPE = el;
        start = s;
    }

    public Element getTYPE()
    {
        return TYPE;
    }

    public long getStart()
    {
        return start;
    }

    @Override
    public boolean equals(Object obj)
    {
        if(obj == null || !(obj instanceof ElementId))
        {
            return false;
        }
        ElementId id = (ElementId)obj;
        return this.TYPE == id.TYPE && this.start == id.start;
    }

    @Override
    public int hashCode()
    {
        int hash = 7;
        hash = 71 * hash + (this.TYPE != null ? this.TYPE.hashCode() : 0);
        hash = 71 * hash + (int) (this.start ^ (this.start >>> 32));
        return hash;
    }

    public int compareTo(ElementId other)
    {
        return other.start - start < 0 ? -1 : other.start - start > 0 ? 1 : 0;
    }
}
